package com.bohua.Car.admin.controller;

import com.bohua.Car.admin.common.Msg;
import com.bohua.Car.admin.common.Pie;
import com.bohua.Car.admin.entity.Cars;
import com.bohua.Car.admin.entity.Customers;
import com.bohua.Car.admin.service.CarsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.bohua.Car.admin.common.Lay;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/Cars")
public class CarsController {

    @Resource
    private CarsService carsService;

   @RequestMapping
    public String cars(){return "Cars/Cars.html";};

    @RequestMapping("/addCars")
    public String addcars(){return "Cars/addCars.html";};

    @RequestMapping("/updateCars")
    public String updete(){return "Cars/updateCars.html";};

    @RequestMapping("/getAll")
    @ResponseBody
    public Lay getAll(Cars cars, Integer page, Integer limit){
        return carsService.getAll(cars,page,limit);
    }

    @RequestMapping("/add")
    @ResponseBody
    public Msg add(Cars cars){return carsService.addCars(cars);};


    @RequestMapping("/Update")
    @ResponseBody
    public Msg Updete(Cars cars){return carsService.updateCars(cars);};

    @RequestMapping("/del")
    @ResponseBody
    public Msg delCar(Cars cars){
        return carsService.delCars(cars);
    }

    @RequestMapping("/Pie")
    @ResponseBody
    public List<Pie> Pie(){
        return carsService.Pie();
    };
}
